package zhishuang.wang.sansi.playlist;

import zhishuang.wang.sansi.tools.ReturnData;

import java.util.List;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:13
 * @Email 1406110602@qq.com
 */

public class PlayList {
    private String id;
    private String name;
    private String version;
    private String codeMode;
    private List<PlayPlan> playPlan;

    public PlayList(String id, String name, List<PlayPlan> playPlan) {
        this.version = "v2021-02-05-001";
        this.codeMode = "UTF-8";
        this.id = id;
        this.name = name;
        this.playPlan = playPlan;
    }

    public PlayList(String id, String name) {
        this.id = id;
        this.name = name;
        this.version = "v2021-02-05-001";
        this.version = "UTF-8";
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        rd.setCode(1);
        String errorMes = "";
        if (this.id != null && this.name != null && this.playPlan != null && this.id.length() != 0 && this.name.length() != 0 && this.playPlan.size() != 0) {
            ReturnData checkRd = null;

            for(int i = 0; i < this.playPlan.size(); ++i) {
                PlayPlan pp = (PlayPlan)this.playPlan.get(i);
                checkRd = pp.checkParam();
                errorMes = errorMes + "播放计划误信息：播放计划项ID：" + pp.getId() + "；" + checkRd.getMessage();
            }
        } else {
            errorMes = errorMes + "播放表唯一ID、播放表名称、播放计划信息等必填；";
        }

        if (errorMes != null && errorMes.length() != 0) {
            rd.setMessage(errorMes);
        } else {
            rd.setCode(0);
        }

        return rd;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getVersion() {
        return this.version;
    }

    public String getCodeMode() {
        return this.codeMode;
    }

    public List<PlayPlan> getPlayPlan() {
        return this.playPlan;
    }

    public void setPlayPlan(List<PlayPlan> playPlan) {
        this.playPlan = playPlan;
    }
}

